import defaultState from '../state/login'
import { fromJS } from 'immutable'

const reducer = (state = defaultState, action) => {
  const type = action.type
  const data = action.data || ''

  switch (type) {
    case 'login':
      let newState = state.set('userinfo', fromJS(data))
      return newState.set('token', fromJS(data.token))
    default:
      return state
  }
}

export default reducer